export type IFetchInstance = typeof fetch;

export type IFetchRequestInfo = RequestInit & { url: string };

export interface IFetchInterceptor {
  request?(
    input: IFetchRequestInfo
  ): Promise<IFetchRequestInfo> | IFetchRequestInfo;
  requestError?(error: any): Promise<any>;
  response?(response: Response): Response | Promise<Response>;
  responseError?(error: any): Promise<any>;
}

export interface IFetchInstanceWrapper extends IFetchInstance {
  use(...interceptors: IFetchInterceptor[]): () => void;
  clear(): void;
}
